package model.tokens;

import java.util.Stack;

import model.semantics.AggregatorNode;
import model.semantics.ConstNode;
import model.semantics.Node;
import model.semantics.RepeatNode;

//TODO: Create resource bundle system for building these things. Also refactoring is needed!
public class RepeatToken extends NodeToken<Integer> {

	public RepeatToken(String label) {
		super(label);
	}

	@Override
	public void process(Stack<Token<Integer>> operatorStack, Stack<Node<Integer>> output) {
		shuntFunctionsToOutput(operatorStack, output);
		
		operatorStack.push(this);
	}

	@Override
	public Node<Integer> makeNewInstance(Stack<Node<Integer>> nodes) {		
		AggregatorNode<Integer> aggregator = (AggregatorNode<Integer>) nodes.pop();
		Node<Integer> numTimes = (Node<Integer>) nodes.pop();
		
		return new RepeatNode(numTimes, aggregator);
	}

}
